#!/usr/bin/env python

"""
This is a test of the database of contacts. It expects the db to be
in such state that
a) there are only DNA - protein contacts
"""

__version__ = "$Id: print_db_stats.py 39 2010-04-06 09:09:31Z sedlakf $"


import sqlite3
import sys

DB = sys.argv[1]

conn = sqlite3.connect(DB)
cur =  conn.cursor()
cur2 = conn.cursor()
    	
tables = cur.execute("""SELECT name FROM sqlite_master
               WHERE type='table' AND name LIKE 'contacts_%'
               ORDER BY name""").fetchall()

print "select type, directness, count(*) from %s group by type, directness"

for (table, ) in tables:
    cur2.execute("select type, directness, count(*) from %s group by type, directness" % table)
    for x in cur2:
        print table, " ".join(str(y) for y in x)
    print
